package org.domain.projeto.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;


public class DateUtil {
	
	public static String FMT_DATA = "dd/MM/yyyy";
	public static String FMT_HORA = "HH:mm:ss";
	public static String FMT_HORA_CURTA = "HH:mm";
	public static String FMT_DATA_HORA = FMT_DATA + " " + FMT_HORA;
	public static String FMT_DATA_HORA_CURTA = FMT_DATA + " " + FMT_HORA_CURTA;
	
	public static Date addDia(Date data) {
		return new Date(data.getTime() + (1000 * 60 * 60 * 24));
	}

	public static Date addDias(Date data, Integer numeroDias) {
		return new Date(data.getTime() + ((1000 * 60 * 60 * 24) * numeroDias));
	}
	
	public static Date formatar(String strFormato, String strDate) {
		SimpleDateFormat format = new SimpleDateFormat(strFormato);
		try {
			return format.parse(strDate);
		} catch (Exception e) {
			return null;
		}
	}
	
	public static Calendar zerarHora(Calendar dataInicio) {
		dataInicio.set(Calendar.HOUR_OF_DAY, 0);
		dataInicio.set(Calendar.MINUTE, 0);
		dataInicio.set(Calendar.SECOND, 0);
		dataInicio.set(Calendar.MILLISECOND, 0);
		return dataInicio;
	}
}
